﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LibNiconico.NiconicoApi.Extentions
{
    internal class TimeSpanExtension
    {
        internal static TimeSpan ParseFromNicoVideoLength(string value)
        {
            string[] valueList = value.Split(':');

            if (valueList.Length != 2) throw new InvalidCastException("適切な位置に区切り文字が存在しません");

            int minutesBase = int.Parse(valueList[0]);
            int hour = minutesBase / 60;
            int minutes = minutesBase % 60;

            return new TimeSpan(hour, minutes, int.Parse(valueList[1]));



        }
    }
}
